package com.ff.discounts.component.address

import android.content.Context
import android.view.ViewGroup
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.QuickViewHolder
import com.ff.discounts.R

/**
 * 收货地址适配器
 */
class AddressAdapter : BaseQuickAdapter<AddressData, QuickViewHolder>() {
    override fun onBindViewHolder(holder: QuickViewHolder, position: Int, data: AddressData?) {
        data?.let { data ->
            holder.setVisible(R.id.default_address, data.isDefault)
            holder.setText(R.id.contact, data.getPeople)
            holder.setText(R.id.area, data.getArea)
            holder.setText(R.id.detail, data.address)
        }
    }

    override fun onCreateViewHolder(
        context: Context,
        parent: ViewGroup,
        viewType: Int
    ): QuickViewHolder {
        return QuickViewHolder(R.layout.item_address, parent)
    }
}